package com.lvyq.myplayer.widget.music

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.lvyq.myplayer.R
import com.lvyq.myplayer.parcelable.SingerInfoData
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.CropCircleTransformation

open class MusicMainView: RelativeLayout {
    lateinit var img: ImageView
    lateinit var singer: TextView
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )


    init {
        View.inflate(context, R.layout.item_singer_grid, this)
        img=findViewById<ImageView>(R.id.singerImg)
        singer=findViewById<TextView>(R.id.singerName)
    }
    fun bind(data: SingerInfoData) {
        Picasso.with(context).load(data.img).transform(CropCircleTransformation()).into(img)
        singer.text=data.name
    }
}